from primes import primes

def isCircle(prime, primes) :
	for p in circles(prime) :
		if not p in primes :
			return False
	return True

def circles(prime) :
	s = list(str(prime))
	cs = []
	for i in range(1, len(s)) :
		s = [s.pop()] + s
		cs.append(int("".join(s)))
	return cs

ps = primes(1e6)
circular = []

for p in ps :
	print "is %s circular" % p
	if isCircle(p, ps) :
		print "  yes"
		circular.append(p)

print "circular", circular
print "len(circular)", len(circular)